from flask import Blueprint, render_template, request
from extensions import db

from modles import User

bp = Blueprint('user', __name__, url_prefix='/user')


# 用户管理
@bp.get('/')
def main():
    return render_template('user/main.html')


#   用户分页查询
@bp.get('/list')
def list():
    user_list = User.query.all()
    for user in user_list:
        print(user)
    return render_template("user/list.html")

    # 用户增加



# 删除用户
@bp.delete('/delete/<int:id>')
def delete(id):
    user = User.query.filter_by(id=id).first()
    db.session.delete(user)
    db.session.commit()
    return "删除成功"


